<?php
include_once 'databaseconnection.php';

$username = $_POST['username'];
$password = $_POST['password'];

if ($username == "") {
    header("Location:http://localhost/stms/pages/index.php?err=Please enter username!");

} else if ($password == "") {
    header("Location:http://localhost/stms/pages/index.php?err=Please enter password!");
} 
else {

    if (auth($username, md5($password),student)) {
        session_start();
        $_SESSION['username'] = $username;
        $_SESSION['password'] = $password;
		
        header("Location:http://localhost/stms/pages/view1.php");
    } 
	else if(auth($username, md5($password),admin1)) {
        session_start();
        $_SESSION['username'] = $username;
        $_SESSION['password'] = $password;
		
        header("Location:http://localhost/stms/pages/HometoAdmin.php");
    } 
	
	
	
	
	else {
        header("Location:http://localhost/stms/pages/index.php?err=Your username or password is incorrect!");
    }
}
?>





